/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.service.catalogue.ws;

import java.text.SimpleDateFormat;
import java.util.Date;
import javax.jws.WebService;
import lombok.extern.slf4j.Slf4j;
import se.riv.itintegration.monitoring.rivtabp21.v1.PingForConfigurationResponderInterface;
import se.riv.itintegration.monitoring.v1.ConfigurationType;
import se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType;
import se.riv.itintegration.monitoring.v1.PingForConfigurationType;

/**
 *
 * @author khaleddaham
 */
@WebService(
        endpointInterface = "se.riv.itintegration.monitoring.rivtabp21.v1.PingForConfigurationResponderInterface",
        serviceName = "PingForConfiguration")
@Slf4j
public class PingForConfiguration implements PingForConfigurationResponderInterface {

    private static final String VERSION = "1.0-SNAPSHOT";

    /**
     *
     * @param message
     * @param configurationType
     * @return
     */
    @Override
    public PingForConfigurationResponseType pingForConfiguration(String message, PingForConfigurationType configurationType) {
        PingForConfigurationResponseType response = new PingForConfigurationResponseType();
        //this.checkAllComponents();
        Date now = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        response.setPingDateTime(format.format(now).toString());
        response.setVersion(VERSION);
        response.getConfiguration().add(getLastImportFromVM());
        response.getConfiguration().add(getJenkinsBuildJob());
        response.getConfiguration().add(getDeployDate());
        response.getConfiguration().add(getAllComponentStatuses());
        return response;
    }

    private ConfigurationType getLastImportFromVM() {
        ConfigurationType ct = new ConfigurationType();
        ct.setName("Last VM1.0 import date");
        ct.setValue("20140122");
        return ct;
    }

    private ConfigurationType getJenkinsBuildJob() {
        ConfigurationType ct = new ConfigurationType();
        ct.setName("Jenkins build job");
        ct.setValue("N/A");
        return ct;
    }

    private ConfigurationType getDeployDate() {
        ConfigurationType ct = new ConfigurationType();
        ct.setName("Deployement date");
        ct.setValue("20140123");
        return ct;
    }

    private ConfigurationType getAllComponentStatuses() {
        ConfigurationType ct = new ConfigurationType();
        ct.setName("HSA");
        ct.setValue("OK");
        return ct;
    }
}